
import { createStore } from 'vuex'
import mutations from "./mutations"
import actions from "./actions"
import createPersistedState from "vuex-persistedstate"

export default createStore({
  state: {
    token: "",
    tabsList: [
      {
        title: "概述",
        name: "/index",
      },
    ],   // 标签页列表
    tabsActiveName: "", // 标签页选中项
    menuCollapse: false,    // true 折叠  false 展开
    user_info: null,


  },
  mutations,
  actions,
  /* vuex数据持久化配置 */
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
      reducer(state: any){
        return {
          // 存储state中的tabsList到会话存储里
          tabsList: state.tabsList,
          tabsActiveName: state.tabsActiveName,
        }
      }
    }),
    createPersistedState({
      storage: window.localStorage,
      reducer(state: any){
        return {
          user_info: state.user_info
        }
      }
    }),
  ]
})